﻿using Basic.FormCollect;
using Basic.FormModel.DataSource;
using Basic.FormRemoteModel.FormDataSource;
using Basic.FormRemoteModel.FormDataSource.Model;
using WeDonekRpc.Client.Interface;
using WeDonekRpc.Helper;

namespace Basic.FormService.RpcEvent
{
    internal class FormSourceEvent : IRpcApiService
    {
        private readonly IFormDataSourceCollect _Service;

        public FormSourceEvent ( IFormDataSourceCollect service )
        {
            this._Service = service;
        }
        public DataSourceItem[] GetFormSourceItems ( GetFormSourceItems obj )
        {
            FormDataSource[] items = this._Service.GetItems(obj.TableType);
            return items.ConvertAll(a => new DataSourceItem
            {
                Id = a.Id,
                Show = a.Show,
                SourceKey = a.SourceKey,
                Template = a.Template,
                Title = a.Title
            });
        }
    }
}
